# -*- coding: utf-8 -*-
"""
Created on Thu Apr  8 12:47:29 2021

@author: User
"""
#BMI = w / (h*h)
import wx

class Example(wx.Frame):
    
    def __init__(self, *args, **kw):
        super(Example, self).__init__(*args, **kw)
        self.BMI = 0.0
        self.InitUI()
    def OnClose(self, e):
        self.Close(True)
    def Compute(self,e):
        #self.BMI = wg_in.GetValue() / (hg_in.GetValue() * hg_in.GetValue())
        print(self.BMI)
        self.BMI += 1.0
        
        
    def InitUI(self):
        pnl = wx.Panel(self)
        st=wx.StaticText(pnl, label='Body mass index', pos=(10, 30))
        wg = wx.StaticText(pnl, label = "weight", pos=(10, 70))
        hg = wx.StaticText(pnl, label = "height", pos=(10, 110))
        
        wg_in = wx.SpinCtrl(pnl, value = "50", pos = (150,70))
        hg_in = wx.SpinCtrl(pnl, value = "50", pos = (150, 110))
        com_btn = wx.Button(pnl, label='Compute', pos=(70, 150))
        
        cbtn = wx.Button(pnl, label='Close', pos=(150, 150))
        cbtn.Bind(wx.EVT_BUTTON, self.OnClose)
        
        #self.BMI = wg_in.GetValue() / (hg_in.GetValue() * hg_in.GetValue())
        com_btn.Bind(wx.EVT_BUTTON, self.Compute)
        bm = wx.StaticText(pnl, label = str(self.BMI), pos = (150, 30))
        print(wg_in.GetValue())
        self.SetSize((300, 250))
        self.SetTitle('BMI')
        self.Centre()
        self.Show(True)

ex = wx.App()
Example(None)
ex.MainLoop() 